#include "gascontroler.h"
#include <QGridLayout>

M_snapClient *GasControler::client = new M_snapClient;

GasControler::GasControler(QObject *parent)
    : QObject{parent}
{


}

void GasControler::autoControl(Controler *c,QString a,QString b){
    c->autoControl(a,b);
}

gasContorolPort* GasControler::createPort(QWidget *W){
    gasContorolPort *port = new gasContorolPort(W);

    QGridLayout *layout = new QGridLayout;
    layout->addWidget(port);
    W->setLayout(layout);

    port->show();
    myPort = port;
    connect(myPort,&gasContorolPort::gasValue,this,[=](float value){
        controlWidget->setGasValue(value);
    });
    connect(myPort,&gasContorolPort::connectIP,this,[=](QString ip,bool flag){
        controlWidget->setIp(ip,flag);
        controlWidget->saveSetDetails();
        controlWidget->readOutput();

    });
    return port;
}

Controler* GasControler::createControl(bool admin){
    controlWidget = new Controler;
    controlWidget->openAdmin(admin);
    return controlWidget;
}
